
{extend name='public/base' /}
{block name="css"}

{/block}
{block name="content"}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox xiaoshi">
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-12 ">
                        <div class="alert alert-info" role="alert">
                            百度站长请前往<a href="https://ziyuan.baidu.com/linksubmit/index" target="_blank" style="color: red">百度站长平台</a>获取Site和Token <br >
                            在系统配置中修改相应配置
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="ibox">
            <div class="ibox-title">
                <h5>百度站长推送文章链接</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-6">
                        <div class="row">
                            <form class="form-horizontal" id="form">

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">推送事件：</label>
                                    <div class="col-sm-8">
                                        <label class="checkbox-inline">
                                            <input type="radio" class="i-checks" name="action" value="urls" checked>新增</label>
                                        <label class="checkbox-inline">
                                            <input type="radio" class="i-checks" name="action" value="del" >删除</label>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">推送链接：</label>
                                    <div class="col-sm-8">
                                        <textarea name="urls" placeholder="一行一个连接"  rows="15"  autocomplete="off" class="form-control"></textarea>
                                    </div>
                                </div>

                                <div class="form-group">

                                </div>

                                <div class="form-group">
                                    <div class="col-sm-8 col-sm-offset-2">
                                        <button type="button" class="btn btn-primary {:node('push.Baidu/zhanzhang')}"  id="ensure">
                                            立即推送
                                        </button>
                                        <button type="reset" class="btn btn-danger" >
                                            重置
                                        </button>
                                    </div>
                                </div>

                            </form>
                        </div>

                    </div>

                    <div class="col-sm-6">
                        <div class="form-group">

                        </div>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">推送结果：</label>
                                <div class="col-sm-8">
                                    <textarea name="result" placeholder="推送结果"  rows="15"  autocomplete="off" class="form-control"></textarea>
                                </div>
                            </div>
                        </div>

                    </div>

                </div>

            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"} <!--js处理区-->

<script>
    $("#ensure").click(function () {
         var cont= $("textarea[name=urls]").val().trim();
         if ($.common.isEmpty(cont)){
             layer.msg("推送链接不能为空");
             return false;
         }
        var btn=$("#ensure");
         btn.addClass("disabled");
        $.ajax({
            beforeSend: function() {
                layer.load(2);
            },
            url: "{:url('zhanzhang')}",
            type: "POST",
            async: true,
            dataType: "json",
            data: $("#form").serialize(),
            error: function(error) {
                layer.msg("服务器错误或超时");
                return false;
            },
            success: function(res) {
                if (res.code == 1) {
                    var html = "状态：成功\n";
                    html += JSON.stringify(res.data);
                    $("textarea[name=result]").val(html);
                } else {
                    var html = "状态：失败\n";
                    html = html + "失败原因：" + res.msg;
                    $("textarea[name=result]").val(html);
                }
            },
            complete: function() {
                btn.removeClass("disabled");
                layer.closeAll('loading');
            }
        });
    })
</script>

{/block}
